package com.myBook.slayer.service.persistence;

import java.util.List;

import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
import com.liferay.util.dao.orm.CustomSQLUtil;
import com.myBook.slayer.model.MyBook;
import com.myBook.slayer.model.impl.MyBookImpl;

public class MyBookFinderImpl extends BasePersistenceImpl implements MyBookFinder {
	
	public static String FIND_BOOKS = MyBookFinderImpl.class.getName()
			+ ".findBooks";

	public List<MyBook> findBooks(String bookTitle) throws SystemException {
		Session session = openSession();

		String sql = CustomSQLUtil.get(FIND_BOOKS);
		
		SQLQuery query = session.createSQLQuery(sql);
		query.addEntity("MyBook", MyBookImpl.class);
		
		QueryPos qPos = QueryPos.getInstance(query);
		qPos.add(bookTitle);
		
		return (List<MyBook>) query.list();
	}


}
